package com.liaoct.lct.adapter;

import java.util.List;

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

/**
 * ViewPager适配器
 * 
 * @version 2013/07/11
 * @author liaoct
 * 
 */
public class ViewPagerAdapter extends PagerAdapter {

	/**
	 * 存放所有VIEW的LIST
	 */
	private List<View> viewList = null;

	/**
	 * 构造方法
	 * 
	 * @param viewList
	 *            参数类型List<View>
	 */
	public ViewPagerAdapter(List<View> viewList) {
		this.viewList = viewList;
	}

	@Override
	public Object instantiateItem(View container, int position) {
		ViewPager viewPager = (ViewPager) container;
		viewPager.addView(viewList.get(position));
		return viewList.get(position);
	}

	@Override
	public void destroyItem(View container, int position, Object object) {
		ViewPager viewPager = (ViewPager) container;
		viewPager.removeView(viewList.get(position));
	}

	@Override
	public CharSequence getPageTitle(int position) {
		return super.getPageTitle(position);
	}

	/**
	 * 总VIEW数量
	 */
	@Override
	public int getCount() {
		return viewList.size();
	}

	/**
	 * 
	 */
	@Override
	public boolean isViewFromObject(View view, Object ob) {
		return view == ob;
	}

}
